/*
 * DXManager.h
 *
 *  Created on: Feb 2, 2010
 *      Author: dcrown
 */

#ifndef DXMANAGER_H_
#define DXMANAGER_H_

#include <d3d9.h>
#include <d3dx9.h>
#include <map>
#include <string>

#include "Sprite.h"

using std::string;

class DXManager
{
public:

	//Creation/Initialization
	DXManager() {Clear();}
	virtual ~DXManager() {}
	void Clear();
	bool Create(HWND hwnd);
	void Destroy() {}

	//Load Objects
	bool LoadTexture(const char* filename, LPDIRECT3DTEXTURE9* texture, int width = D3DX_DEFAULT, int height = D3DX_DEFAULT);
	bool LoadSprite(LPD3DXSPRITE* sprite);
	//bool LoadTexturedSprite(const char* filename, string spriteId, string textId, int width = D3DX_DEFAULT, int height = D3DX_DEFAULT);

	//Draw Objects
	bool BeginRender();
	bool EndRender();

	//Manipulate Objects
	//bool ScaleSprite(string id, float x, float y);
	//bool TranslateSprite(string id, int x, int y);
	//bool RotateSprite(string id, float rads);
	//bool UpdateSprite(string id);

	//Access Objects
	//Sprite* GetSprite(string id);
	//LPDIRECT3DTEXTURE9 GetTexture(string id);
	void ApplyTransform(LPD3DXSPRITE* sprite, D3DXVECTOR2* scalingCenter, float scalingRotation, D3DXVECTOR2* scale,
			D3DXVECTOR2* rotCenter, float rotation, D3DXVECTOR2* translation);
	void Draw(LPD3DXSPRITE sprite, LPDIRECT3DTEXTURE9 texture, RECT* r = NULL);


private:
	LPDIRECT3D9 d3d;
	LPDIRECT3DDEVICE9 device;
};

#endif /* DXMANAGER_H_ */
